<%@ page language="java" pageEncoding="UTF-8" contentType="text/html; charset=utf-8" errorPage="/error.jsp" isELIgnored="false" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-html" prefix="html" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-logic" prefix="logic" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-tiles" prefix="tiles" %>
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jstl/fmt" prefix="fmt" %>
<%@ taglib uri="http://www.opensymphony.com/oscache" prefix="cache" %>
<%@ taglib uri="http://atleap.blandware.com/taglib" prefix="atleap" %>
<html:xhtml />

<atleap:constants className="com.blandware.atleap.webapp.util.core.WebappConstants" var="HTML_TEXT_FIELD_MAX_LENGTH" />
<atleap:constants className="com.blandware.atleap.webapp.util.core.WebappConstants" scope="page" var="HIT_COLLECTION_KEY" />
<atleap:constants className="com.blandware.atleap.webapp.util.core.WebappConstants" scope="page" var="HITS_GRID" />
<atleap:constants className="com.blandware.atleap.webapp.util.core.WebappConstants" var="GRID_PAGE_SIZE" />
<atleap:globalProperty name="${pageScope.GRID_PAGE_SIZE}" defaultValue="10" type="integer" var="pageSize" />
<atleap:javascript formName="searchForm" staticJavascript="false" dynamicJavascript="true" method="validateForm" cdata="false" />
<atleap:form action="core/search/search" onsubmit="var result = validateForm(this) && doCheckLuceneQuery(this.query); disableButtons(this, result); return result;">
     <div><atleap:label property="query" styleClass="label" key="core.search.form.query" colon="false" helpTip="false" /></div>
     <div class="searchQuery">
        <html:text styleClass="text" maxlength="${pageScope.HTML_TEXT_FIELD_MAX_LENGTH}" property="query" />
        <atleap:submit styleClass="button"><atleap:message key="core.commons.buttons.search" /></atleap:submit>
    </div>
    <div style="clear: both;">
         <html:hidden property="timePeriod" value="0" />
         <atleap:link action="core/search/callSearch"><atleap:message key="core.search.form.advancedSearch" /></atleap:link>
    </div>
</atleap:form>

<atleap:grid name="${pageScope.HITS_GRID}" pageSize="${pageSize}" pageUrl="${pageContext.request.contextPath}/core/search/search.do">
    <atleap:rowsIterator var="hit" oddClass="oddRow" evenClass="evenRow" collection="${requestScope[pageScope.HIT_COLLECTION_KEY]}">
        <a href="${hit.uri}" target="_blank">${hit.title}</a>
        <br />
        <c:if test="${hit.highlightedText != null}">${hit.highlightedText}<br /></c:if>
        <c:out value="${hit.score}" escapeXml="true" /> - <a href="${hit.uri}" target="_blank"><c:out value="${hit.uri}" escapeXml="true" /></a> : <c:out value="${hit.modified}" escapeXml="true" />
        <br /><br />

    </atleap:rowsIterator>


    <atleap:noRows>
        <em><atleap:message key="core.search.noPages"/></em>
    </atleap:noRows>
    <atleap:pager pageCount="10">
        <atleap:message key="core.grid.pager.title" />&nbsp;
        <atleap:firstPage><img src="<atleap:rewriteUrl href="/images/theme/${appConfig['frontendCssTheme']}/first.gif" />" border="0" alt="<atleap:message key="core.grid.pager.first"/>"  /></atleap:firstPage>
        <atleap:prevPage><img src="<atleap:rewriteUrl href="/images/theme/${appConfig['frontendCssTheme']}/prev.gif" />" border="0" alt="<atleap:message key="core.grid.pager.prev"/>"  /></atleap:prevPage>
        <atleap:pagesIterator>
            <atleap:page>${pageNumber}&nbsp;</atleap:page>
            <atleap:currentPage><b>${pageNumber}</b>&nbsp;</atleap:currentPage>
        </atleap:pagesIterator>
        <atleap:nextPage><img src="<atleap:rewriteUrl href="/images/theme/${appConfig['frontendCssTheme']}/next.gif" />" border="0" alt="<atleap:message key="core.grid.pager.next"/>"  /></atleap:nextPage>
        <atleap:lastPage><img src="<atleap:rewriteUrl href="/images/theme/${appConfig['frontendCssTheme']}/last.gif" />" border="0" alt="<atleap:message key="core.grid.pager.last"/>"  /></atleap:lastPage>
   </atleap:pager>
</atleap:grid>
